﻿@using Microsoft.AspNetCore.Components.Routing
@using ThingsGateway.Admin.Application
@namespace ThingsGateway

@{
    #if NET6_0
}
<Microsoft.AspNetCore.Components.Authorization.CascadingAuthenticationState>

<Router AppAssembly="@typeof(Routes).Assembly" AdditionalAssemblies="App.RazorAssemblies.Where(a=>a!=typeof(Routes).Assembly)">
<Found Context="routeData">

    <Microsoft.AspNetCore.Components.Authorization.AuthorizeView Resource="routeData">
                <Authorized>
                    <RouteView RouteData="routeData" DefaultLayout="typeof(Razor.MainLayout)">
                    </RouteView>
                </Authorized>
                <NotAuthorized>
                    @if (UserManager.UserId > 0)
                    {
                        <LayoutView Layout="typeof(Razor.BaseLayout)">
                            <ThingsGateway.Admin.Razor.AccessDenied/>
                        </LayoutView>
                    }
                    else
                    {
                        <LayoutView Layout="typeof(Razor.BaseLayout)">
                            <ThingsGateway.Admin.Razor.Login/>
                        </LayoutView>
                    }
                </NotAuthorized>
            </Microsoft.AspNetCore.Components.Authorization.AuthorizeView>


</Found>
<NotFound>
    <LayoutView Layout="@typeof(Razor.BaseLayout)">
    <ThingsGateway.Admin.Razor.NotFound404></ThingsGateway.Admin.Razor.NotFound404>
        </LayoutView>
    </NotFound>
</Router>



</Microsoft.AspNetCore.Components.Authorization.CascadingAuthenticationState>


@{
    #else
}
<Router AppAssembly="@typeof(Routes).Assembly" AdditionalAssemblies="App.RazorAssemblies.Where(a=>a!=typeof(Routes).Assembly)">
<Found Context="routeData">

    <RouteView RouteData="@routeData" DefaultLayout="@typeof(Razor.MainLayout)" />


</Found>
<NotFound>
    <LayoutView Layout="@typeof(Razor.BaseLayout)">
    <ThingsGateway.Admin.Razor.NotFound404></ThingsGateway.Admin.Razor.NotFound404>
        </LayoutView>
    </NotFound>
</Router>

@{
    #endif
}

